Ext
		.onReady(function() {
			Ext.QuickTips.init();
			Ext.form.Field.prototype.msgTarget = 'under';
			var classgrade = function(val) {
				if (val == '一年级') {
					return "一年级";
				} else if (val == '二年级') {
					return "二年级";
				} else if (val == '三年级') {
					return "三年级";
				} else if (val == '四年级') {
					return "四年级";
				}
			};

			var gradestore = new Ext.data.SimpleStore( {
				fields : [ "retrunValue", "displayText" ],
				data : [ [ '一年级', '一年级' ], [ '二年级', '二年级' ], [ '三年级', '三年级' ],
						[ '四年级', '四年级' ] ]
			});

			var systems = new Ext.data.Record.create( [ {
				name : 'systems_id',
				type : 'int'
			}, {
				name : 'systems_name',
				type : 'string'
			}, {
				name : 'systems_sysFlag',
				type : 'int'
			} ]);
			var systemsstore;
			function getSystemsData(val) {
				var url = "/schedule/querySystems?flag="
						+ encodeURI(encodeURI(val));
				systemsstore = new Ext.data.Store( {
					id : "systems_id",
					proxy : new Ext.data.HttpProxy( {
						url : url
					}),
					reader : new Ext.data.JsonReader( {
						totalProperty : 'totalProperty',
						root : 'root'
					}, systems),
					remoteSort : true
				});
				if (val != undefined) {
					grid.reconfigure(systemsstore, cols);
				}
				systemsstore.load( {
					params : {
						start : 0,
						limit : 30
					}
				});
			}
			;
			getSystemsData();

			var professional = new Ext.data.Record.create( [ {
				name : 'professional_id',
				type : 'int'
			}, {
				name : 'professional_systems.systems_name',
				type : 'string'
			}, {
				name : 'professional_systems.systems_id',
				type : 'int'
			}, {
				name : 'professional_name',
				type : 'string'
			}, {
				name : 'professional_sysFlag',
				type : 'int'
			} ]);

			var professionalstore;
			function getProfessionalData(val) {
				var url = "/schedule/queryProfessional?flag="
						+ encodeURI(encodeURI(val));
				professionalstore = new Ext.data.Store( {
					id : "professional_id",
					proxy : new Ext.data.HttpProxy( {
						url : url
					}),
					reader : new Ext.data.JsonReader( {
						totalProperty : 'totalProperty',
						root : 'root'
					}, professional),
					remoteSort : true
				});
				if (val != undefined) {
					grid.reconfigure(professionalstore, cols);
				}
				professionalstore.load( {
					params : {
						start : 0,
						limit : 15
					}
				});
			}
			;
			getProfessionalData();

			var classes = new Ext.data.Record.create( [ {
				name : 'classes_id',
				type : 'int'
			}, {
				name : 'classes_code',
				type : 'string'
			}, {
				name : 'classes_name',
				type : 'string'
			}, {
				name : 'classes_grade',
				type : 'string'
			}, {
				name : 'classes_password',
				type : 'string'
			}, {
				name : 'classes_number',
				type : 'string'
			}, {
				name : 'classes_sysFlag',
				type : 'string'
			}, {
				name : 'classes_professional.professional_id',
				type : 'int'
			}, {
				name : 'classes_professional.professional_name',
				type : 'string'
			}, {
				name : 'classes_systems.systems_id',
				type : 'int'
			}, {
				name : 'classes_systems.systems_name',
				type : 'string'
			} ]);

			var classesstore;
			function getData(val) {
				var url = "/schedule/queryClasses?flag="
						+ encodeURI(encodeURI(val));
				classesstore = new Ext.data.Store( {
					id : "professional_id",
					proxy : new Ext.data.HttpProxy( {
						url : url
					}),
					reader : new Ext.data.JsonReader( {
						totalProperty : 'totalProperty',
						root : 'root'
					}, classes),
					remoteSort : true
				});
				if (val != undefined) {
					grid.reconfigure(classesstore, cols);
				}
				classesstore.load( {
					params : {
						start : 0,
						limit : 15
					}
				});
			}
			;
			getData();

			var sm = new Ext.grid.CheckboxSelectionModel();
			var cols = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(),
					sm, {
						header : '班级名称',
						dataIndex : 'classes_name'
					}, {
						header : '年级',
						dataIndex : 'classes_grade',
						renderer : classgrade
					}, {
						header : '人数',
						dataIndex : 'classes_number'
					}, {
						header : '所属学院',
						dataIndex : 'classes_systems.systems_name'
					}, {
						header : '专业',
						dataIndex : 'classes_professional.professional_name'
					} ]);
			cols.defaultSortable = true;

			var courses = new Ext.data.Record.create( [ {
				name : 'course_id',
				type : 'int'
			}, {
				name : 'course_name',
				type : 'string'
			}, {
				name : 'course_code',
				type : 'string'
			} ]);
			var coursestore = new Ext.data.Store( {
				proxy : new Ext.data.HttpProxy( {
					url : '/schedule/queryCourse'
				}),
				reader : new Ext.data.JsonReader( {
					totalProperty : 'totalProperty',
					root : 'root'
				}, courses),
				remoteSort : true
			});
			coursestore.load();
			var courseSm = new Ext.grid.CheckboxSelectionModel();
			var courseCols = new Ext.grid.ColumnModel( [
					new Ext.grid.RowNumberer(), courseSm, {
						header : '课程名称',
						dataIndex : 'course_name'
					}, {
						header : '课程编号',
						dataIndex : 'course_code'
					} ]);
			courseCols.defaultSortable = true;
			var classes_ids="";

			var courseGrid = new Ext.grid.GridPanel(
					{
						title : '课程信息列表',
						region : 'west',
						buttonAlign : "left",
						width : 450,
						height : 460,
						loadMask : true,
						store : coursestore,
						disableSelection : false,
						cm : courseCols,
						sm : courseSm,
						viewConfig : {
							forceFit : true
						},
						buttons : [ {
							text : "添加关联课程",
							listeners : {
								click : function() {
									var course_ids = "";
									var records = courseGrid.getSelectionModel()
											.getSelections();
									if ("" == records) {
										Ext.MessageBox.alert("提示", "请选择要添加课程");
									} else {
										for ( var i = 0; i < records.length; i++) {
											course_ids += records[i]
													.get("course_id")
													+ ",";
										};
										Ext.Ajax
												.request( {
													url : '/schedule/addToCourseRClass',
													params : {
														classes_ids : classes_ids,
														course_ids : course_ids
													},
													method : 'POST',
													success : function(
															form,
															action) {
														Ext.Msg
																.alert(
																		"系统消息",
																		"添加关联成功",
																		function() {
																			addToCourseWin.close();
																			window.parent.frames['mainFrame'].location
																			.reload('queryClass.jsp');
																		},
																		this);
													},
													failure : function(
															form,
															action) {
														Ext.Msg
																.alert(
																		"系统消息",
																		"添加关联失败",
																		function() {
																			addToCourseWin.close();
																			window.parent.frames['mainFrame'].location
																			.reload('queryClass.jsp');
																		},
																		this);
													}
												});
									
									}
								}
							}

						},{
							text : "取消关联课程",
							listeners : {
								click : function() {
									var course_ids = "";
									var records = courseGrid.getSelectionModel()
											.getSelections();
									if ("" == records) {
										Ext.MessageBox.alert("提示", "请选择要取消关联的课程");
									} else {
										for ( var i = 0; i < records.length; i++) {
											course_ids += records[i]
													.get("course_id")
													+ ",";
										};
										Ext.Ajax
												.request( {
													url : '/schedule/delFromCourseRClass',
													params : {
														classes_ids : classes_ids,
														course_ids : course_ids
													},
													method : 'POST',
													success : function(
															form,
															action) {
														Ext.Msg
																.alert(
																		"系统消息",
																		"取消关联成功",
																		function() {
																			addToCourseWin.close();
																			window.parent.frames['mainFrame'].location
																			.reload('queryClass.jsp');
																		},
																		this);
													},
													failure : function(
															form,
															action) {
														Ext.Msg
																.alert(
																		"系统消息",
																		"取消关联失败",
																		function() {
																			addToCourseWin.close();
																			window.parent.frames['mainFrame'].location
																			.reload('queryClass.jsp');
																		},
																		this);
													}
												});
									
									}
								}
							}

						
							
						} ],
						bbar : new Ext.PagingToolbar( {
							store : coursestore,
							pageSize : 15,// 页大小
							displayInfo : true,// 是否显示displayMsg
							displayMsg : "本页显示第{0}条到第{1}条的记录,一共{2}条",
							emptyMsg : "没有记录"// 如果没有记录，则显示该文本
						})
					});
			var addToCourseWin = new Ext.Window( {
				layout : 'fit',
				title : '班级信息',
				width : 450,
				height : 480,
				resizable : true,
				closeAction : 'close',
				plain : true,
				items : courseGrid,
				listeners : {
					close : function(w) {
						w.restore();
					},
					maximize : function(w) {
					}
				}
			});
			var addToCourse = function(val) {
				addToCourseWin.show();
			}
			
			
			var openwin = function() {
				var classesform = new Ext.form.FormPanel(
						{
							region : 'center',
							frame : true,
							layout : "form", // 整个大的表单是form布局
							labelWidth : 65,
							labelAlign : "right",
							maximizable : true,
							items : [
									{ // 行1
										layout : "column", // 从左往右的布局
										items : [
												{
													columnWidth : .5,
													layout : "form",
													items : [ {
														xtype : "textfield",
														allowBlank : false,
														validateOnBlur : true,
														name : "classes.classes_name",
														fieldLabel : "班级名称",
														blankText : '必须填写',
														validateOnBlur : true,
														width : 120
													} ]
												},
												{
													columnWidth : .5,
													layout : "form",
													items : [ {
														xtype : 'combo',
														store : systemsstore,
														valueField : "systems_id",
														displayField : "systems_name",
														mode : 'local',
														forceSelection : true,
														blankText : '请选择所属院系',
														emptyText : '选择院系',
														hiddenName : 'classes.classes_systems.systems_id',
														editable : false,
														triggerAction : 'all',
														validateOnBlur : true,
														allowBlank : false,
														fieldLabel : '所属院系',
														width : 140,
														listeners : {
															select : function(
																	combo) {
																professionalstore.proxy = new Ext.data.HttpProxy(
																		{
																			url : '/schedule/queryProfessional?systems_id=' + combo.value
																		});
																professionalstore
																		.load();
															}
														}
													} ]
												} ]
									},
									{ // 行2
										layout : "column",
										items : [ {
											columnWidth : .5,
											layout : "form",
											items : [ {
												xtype : 'combo',
												store : gradestore,
												valueField : "retrunValue",
												displayField : "displayText",
												mode : 'local',
												forceSelection : true,
												blankText : '请选择所在年级',
												emptyText : '年级',
												hiddenName : 'classes.classes_grade',
												editable : false,
												triggerAction : 'all',
												allowBlank : false,
												validateOnBlur : true,
												fieldLabel : "年级",
												width : 120
											} ]
										}, {
											columnWidth : .5,
											layout : "form",
											items : [ {
												xtype : "textfield",
												name : "classes.classes_number",
												blankText : '必须填写',
												validateOnBlur : true,
												allowBlank : false,
												fieldLabel : "人数",
												width : 120
											} ]
										} ]
									},
									{
										columnWidth : .8,
										layout : "form",
										items : [ {
											xtype : 'combo',
											store : professionalstore,
											valueField : "professional_id",
											displayField : "professional_name",
											mode : 'local',
											forceSelection : true,
											blankText : '请选择所属专业',
											emptyText : '选择专业',
											hiddenName : 'classes.classes_professional.professional_id',
											editable : false,
											triggerAction : 'all',
											validateOnBlur : true,
											allowBlank : false,
											fieldLabel : '所属专业',
											width : 120
										} ]
									}, {//行8
										buttonAlign : "right",
										buttons : [
												{
													text : "保存",
													handler : function() {
														if (classesform.form
																.isValid()) {
															classesform.form
																	.submit( {
																		waitTitle : '请稍候',
																		waitMsg : '正在保存......',
																		url : '/schedule/addClasses',
																		success : function(
																				form,
																				action) {
																			Ext.Msg
																					.alert(
																							"系统消息",
																							action.result.msg,
																							function() {
																								form
																										.reset();
																								win
																										.close();
																								classesstore
																										.reload();
																							},
																							this);
																		},
																		failure : function(
																				form,
																				action) {
																			Ext.Msg
																					.alert(
																							'系统消息',
																							action.result.msg);
																			form
																					.reset();
																			win
																					.close();
																		}
																	})
														}

													}
												},
												{
													text : "重置",
													listeners : {
														click : function() {
															classesform.form
																	.reset()
														}
													}
												} ]
									} ]

						});

				var win = new Ext.Window( {
					layout : 'fit',
					title : '班级属性',
					width : 480,
					height : 200,
					resizable : true,
					closeAction : 'close',
					plain : true,
					items : classesform,
					listeners : {
						close : function(w) {
							classesstore.load();
							w.restore();
						},
						maximize : function(w) {
							//w.setPosition(document.body.scrollLeft,document.body.scrollTop);
					}
					}
				}).show();
			};

			var grid = new Ext.grid.GridPanel(
					{
						title : '班级信息列表',
						region : 'center',
						buttonAlign : "left",
						listeners : {
							"rowdblclick" : function(grid, rowIndex, e) {
								var records = grid.getSelectionModel()
										.getSelections();
								var changeform = new Ext.form.FormPanel(
										{
											region : 'center',
											frame : true,
											layout : "form", // 整个大的表单是form布局
											labelWidth : 65,
											labelAlign : "right",
											maximizable : true,
											items : [ { // 行1
														layout : "column", // 从左往右的布局
														items : [
																{
																	columnWidth : .5,
																	layout : "form",
																	items : [ {
																		xtype : "textfield",
																		allowBlank : false,
																		validateOnBlur : true,
																		name : "classes.classes_name",
																		value : records[0]
																				.get("classes_name"),
																		fieldLabel : "课程名称",
																		blankText : '必须填写',
																		width : 120
																	} ]
																},
																{
																	columnWidth : .4,
																	layout : "form",
																	items : [
																			{
																				xtype : "hidden",
																				blankText : '必须填写',
																				name : "classes.classes_code",
																				value : records[0]
																						.get("classes_code"),
																				fieldLabel : "课程编号",
																				width : 120
																			},
																			{
																				xtype : "hidden",
																				allowBlank : false,
																				blankText : '必须填写',
																				name : "classes.classes_password",
																				value : records[0]
																						.get("classes_password"),
																				fieldLabel : "课程编号",
																				width : 120
																			} ]
																},
																{
																	columnWidth : .5,
																	layout : "form",
																	items : [ {
																		xtype : 'combo',
																		store : gradestore,
																		valueField : "retrunValue",
																		displayField : "displayText",
																		mode : 'local',
																		forceSelection : true,
																		blankText : '请选择所在年级',
																		emptyText : '年级',
																		hiddenName : 'classes.classes_grade',
																		editable : false,
																		triggerAction : 'all',
																		value : classgrade(records[0]
																				.get("classes_grade")),
																		allowBlank : false,
																		fieldLabel : "年级",
																		width : 120
																	} ]
																} ]
													}, { // 行2
														layout : "column",
														items : [
																{
																	columnWidth : .5,
																	layout : "form",
																	items : [ {
																		xtype : "numberfield",
																		name : "classes.classes_number",
																		value : records[0]
																				.get("classes_number"),
																		blankText : '必须填写',
																		allowBlank : false,
																		fieldLabel : "人数",
																		width : 120
																	} ]
																},
																{
																	columnWidth : .5,
																	layout : 'form',
																	border : false,
																	items : [ {
																		xtype : 'combo',
																		store : systemsstore,
																		valueField : "systems_id",
																		displayField : "systems_name",
																		value : records[0]
																				.get("classes_systems.systems_id"),
																		mode : 'local',
																		forceSelection : true,
																		blankText : '请选择所属院系',
																		emptyText : '选择院系',
																		hiddenName : 'classes.classes_systems.systems_id',
																		editable : false,
																		triggerAction : 'all',
																		allowBlank : false,
																		fieldLabel : '所属院系',
																		width : 140,
																		listeners : {
																			select : function(
																					combo) {
																				professionalstore.proxy = new Ext.data.HttpProxy(
																						{
																							url : '/schedule/queryProfessional?systems_id=' + combo.value
																						});
																				professionalstore
																						.load();
																			}
																		}
																	} ]
																} ]
													}, { // 行3
														layout : "column",
														items : [ {
															columnWidth : .8,
															layout : "form",
															items : [ {
																xtype : 'combo',
																store : professionalstore,
																valueField : "professional_id",
																displayField : "professional_name",
																value : records[0]
																		.get("classes_professional.professional_id"),
																mode : 'local',
																forceSelection : true,
																blankText : '请选择所属专业',
																emptyText : '选择专业',
																hiddenName : 'classes.classes_professional.professional_id',
																editable : false,
																triggerAction : 'all',
																allowBlank : false,
																fieldLabel : '所属专业',
																width : 120
															} ]
														} ]
													}, {// 行4
														layout : "form",
														items : [
																{
																	xtype : "hidden",
																	name : "classes.classes_id",
																	value : records[0]
																			.get("classes_id"),
																	fieldLabel : "ID",
																	enableLists : false,
																	enableSourceEdit : false,
																	height : 120
																},
																{
																	xtype : "hidden",
																	name : "classes.classes_sysFlag",
																	value : records[0]
																			.get("classes_sysFlag"),
																	fieldLabel : "SysFlag",
																	enableLists : false,
																	enableSourceEdit : false,
																	height : 120
																}, {//行8
																	buttonAlign : "right",
																	buttons : [
																			{
																				text : "修改",
																				handler : function() {
																					if (changeform.form
																							.isValid()) {
																						changeform.form
																								.submit( {
																									waitTitle : '请稍候',
																									waitMsg : '正在保存......',
																									url : '/schedule/addClasses',
																									success : function(
																											form,
																											action) {
																										Ext.Msg
																												.alert(
																														"系统消息",
																														action.result.msg,
																														function() {
																															form
																																	.reset();
																															changewin
																																	.close();
																														},
																														this);
																									},
																									failure : function(
																											form,
																											action) {
																										Ext.Msg
																												.alert(
																														'系统消息',
																														action.result.msg);
																										form
																												.reset();
																										changewin
																												.close();
																									}
																								})
																					}

																				}
																			},
																			{
																				text : "重置",
																				listeners : {
																					click : function() {
																						changeform.form
																								.reset()
																					}
																				}
																			} ]
																} ]
													} ]
										});

								var changewin = new Ext.Window( {
									layout : 'fit',
									title : '班级属性',
									width : 480,
									height : 200,
									resizable : true,
									closeAction : 'close',
									plain : true,
									items : changeform,
									listeners : {
										close : function(w) {
											classesstore.reload();
											w.restore();
										},
										maximize : function(w) {

										}
									}
								});

								changewin.show();
							}
						},
						buttons : [
								{
									text : "新增",
									listeners : {
										click : function() {
											professionalstore.reload();
											openwin();
										}
									}
								},
								{
									text : "删除",
									listeners : {
										click : function() {
											var ids = "";
											var records = grid
													.getSelectionModel()
													.getSelections();
											if ("" == records) {
												Ext.MessageBox.alert("提示",
														"请选择要删除的记录");
											} else {
												for ( var i = 0; i < records.length; i++) {

													ids += records[i].get("classes_id")
															+ ",";

												}
												;
												Ext.MessageBox
														.confirm(
																"确认删除",
																"确认删除所选数据？",
																function(button) {
																	if (button == "yes") {
																		Ext.Ajax
																				.request( {
																					url : '/schedule/deleteClasses',
																					params : {
																						ids : ids
																					},
																					method : 'POST',
																					success : function(
																							form,
																							action) {
																						Ext.Msg
																								.alert(
																										"系统消息",
																										"删除成功",
																										function() {
																											window.location.reload(); 
																										},
																										this);
																					},
																					failure : function(
																							form,
																							action) {
																						Ext.Msg
																								.alert(
																										"系统消息",
																										"删除失败",
																										function() {
																											window.location.reload(); 
																										},
																										this);
																					},
																					scope : this
																				});
																	}
																}, this);
											}
										}
									}
								},
								{
									text : "修改",
									listeners : {
										click : function() {
											professionalstore.reload();
											var record = grid
													.getSelectionModel()
													.getSelected();
											if (!record) {
												Ext.Msg.alert("提示",
														"请先选择要修改的行!");
												return;
											}
											var changeform = new Ext.form.FormPanel(
													{
														region : 'center',
														frame : true,
														layout : "form", // 整个大的表单是form布局
														labelWidth : 65,
														labelAlign : "right",
														maximizable : true,
														items : [
																{ // 行1
																	layout : "column", // 从左往右的布局
																	items : [
																			{
																				columnWidth : .5,
																				layout : "form",
																				items : [ {
																					xtype : "textfield",
																					allowBlank : false,
																					validateOnBlur : true,
																					name : "classes.classes_name",
																					value : record
																							.get("classes_name"),
																					fieldLabel : "课程名称",
																					blankText : '必须填写',
																					width : 120
																				} ]
																			},
																			{
																				columnWidth : .5,
																				layout : "form",
																				items : [ {
																					xtype : 'combo',
																					store : gradestore,
																					valueField : "retrunValue",
																					displayField : "displayText",
																					mode : 'local',
																					forceSelection : true,
																					blankText : '请选择所在年级',
																					emptyText : '年级',
																					hiddenName : 'classes.classes_grade',
																					editable : false,
																					triggerAction : 'all',
																					value : classgrade(record
																							.get("classes_grade")),
																					allowBlank : false,
																					fieldLabel : "年级",
																					listeners : {
																						'blur' : function(
																								text) {
																							if (combo.value == null) {
																								this
																										.focus();
																							}
																						}
																					},
																					width : 120
																				} ]
																			} ]
																},
																{ // 行2
																	layout : "column",
																	items : [
																			{
																				columnWidth : .5,
																				layout : "form",
																				items : [ {
																					xtype : "numberfield",
																					name : "classes.classes_number",
																					value : record
																							.get("classes_number"),
																					blankText : '必须填写',
																					allowBlank : false,
																					fieldLabel : "人数",
																					width : 120
																				} ]
																			},
																			{
																				columnWidth : .5,
																				layout : "form",
																				items : [ {
																					xtype : 'combo',
																					store : systemsstore,
																					valueField : "systems_id",
																					displayField : "systems_name",
																					value : record
																							.get("classes_systems.systems_id"),
																					mode : 'local',
																					forceSelection : true,
																					blankText : '请选择所属院系',
																					emptyText : '选择院系',
																					hiddenName : 'classes.classes_systems.systems_id',
																					editable : false,
																					triggerAction : 'all',
																					allowBlank : false,
																					fieldLabel : '所属院系',
																					width : 140,
																					listeners : {
																						select : function(
																								combo) {
																							professionalstore.proxy = new Ext.data.HttpProxy(
																									{
																										url : '/schedule/queryProfessional?systems_id=' + combo.value
																									});
																							professionalstore
																									.load();
																						}
																					}
																				} ]
																			} ]
																},
																{
																	columnWidth : .8,
																	layout : 'form',
																	border : false,
																	items : [ {
																		xtype : 'combo',
																		store : professionalstore,
																		valueField : "professional_id",
																		displayField : "professional_name",
																		value : record
																				.get("classes_professional.professional_id"),
																		mode : 'local',
																		forceSelection : true,
																		blankText : '请选择所属专业',
																		emptyText : '选择专业',
																		hiddenName : 'classes.classes_professional.professional_id',
																		editable : false,
																		triggerAction : 'all',
																		allowBlank : false,
																		fieldLabel : '所属专业',
																		width : 120
																	} ]
																}, {// 行7
																	layout : "form",
																	items : [
																			{
																				xtype : "hidden",
																				name : "classes.classes_id",
																				value : record
																						.get("classes_id"),
																				fieldLabel : "ID",
																				enableLists : false,
																				enableSourceEdit : false,
																				height : 120
																			},
																			{
																				xtype : "hidden",
																				allowBlank : false,
																				validateOnBlur : true,
																				blankText : '必须填写',
																				name : "classes.classes_password",
																				value : record
																						.get("classes_password"),
																				fieldLabel : "班级密码",
																				width : 120
																			},
																			{
																				xtype : "hidden",
																				allowBlank : false,
																				blankText : '必须填写',
																				name : "classes.classes_code",
																				value : record
																						.get("classes_code"),
																				fieldLabel : "班级编号",
																				width : 120
																			},
																			{
																				xtype : "hidden",
																				name : "classes.classes_sysFlag",
																				value : record
																						.get("classes_sysFlag"),
																				fieldLabel : "SysFlag",
																				enableLists : false,
																				enableSourceEdit : false,
																				height : 120
																			},
																			{//行8
																				buttonAlign : "right",
																				buttons : [
																						{
																							text : "修改",
																							handler : function() {
																								if (changeform.form
																										.isValid()) {
																									changeform.form
																											.submit( {
																												waitTitle : '请稍候',
																												waitMsg : '正在保存......',
																												url : '/schedule/addClasses',
																												success : function(
																														form,
																														action) {
																													Ext.Msg
																															.alert(
																																	"系统消息",
																																	action.result.msg,
																																	function() {
																																		form
																																				.reset();
																																		changewin
																																				.close();

																																	},
																																	this);
																												},
																												failure : function(
																														form,
																														action) {
																													Ext.Msg
																															.alert(
																																	'系统消息',
																																	action.result.msg);
																													form
																															.reset();
																													changewin
																															.close();

																												}
																											})
																								}

																							}
																						},
																						{
																							text : "重置",
																							listeners : {
																								click : function() {
																									changeform.form
																											.reset()
																								}
																							}
																						} ]
																			} ]
																} ]
													});

											var changewin = new Ext.Window( {
												layout : 'fit',
												title : '班级属性',
												width : 480,
												height : 200,
												resizable : true,
												closeAction : 'close',
												plain : true,
												items : changeform,
												listeners : {
													close : function(w) {
														classesstore.reload();
														w.restore();
													},
													maximize : function(w) {

													}
												}
											});

											changewin.show();
										}

									}
								},{


									text : "管理该班级所上的课程",
									listeners : {
										click : function() {
											var records = grid
													.getSelectionModel()
													.getSelections();
											if ("" == records) {
												Ext.MessageBox.alert("提示",
														"请选择要管理课程的班级");
											} else {
												for ( var i = 0; i < records.length; i++) {

													classes_ids += records[i]
															.get("classes_id")
															+ ",";
												}
												;
												Ext.MessageBox
														.confirm(
																"确认管理",
																"确认管理所选班级？",
																function(button) {
																	if (button == "yes") {
																		addToCourse(classes_ids);
																	}else{}
																}, this);
											}
										}
									}
								
								} ],
						loadMask : true,
						store : classesstore,
						cm : cols,
						sm : new Ext.grid.RowSelectionModel( {
							singleSelect : false
						}),
						viewConfig : {
							forceFit : true
						},
						bbar : new Ext.PagingToolbar( {
							store : classesstore,
							pageSize : 15,//页大小 
							displayInfo : true,//是否显示displayMsg 
							displayMsg : "本页显示第{0}条到第{1}条的记录,一共{2}条",
							emptyMsg : "没有记录"//如果没有记录，则显示该文本 
						})

					});

			var form = new Ext.form.FormPanel(
					{
						region : "north",
						id : "form",
						width : 650,
						height : 76,
						hideBorders : true,
						layout : "form", // 整个大的表单是form布局
						labelWidth : 80,
						labelAlign : "right",
						items : [ { // 行1
							layout : "column", // 从左往右的布局
							hideBorders : true,
							items : [
									{
										columnWidth : .2,
										layout : "form",
										items : [ {
											xtype : 'combo',
											store : systemsstore,
											valueField : "systems_id",
											displayField : "systems_name",
											mode : 'local',
											forceSelection : true,
											blankText : '请选择所属院系',
											emptyText : '选择院系',
											hiddenName : 'flag2',
											editable : false,
											triggerAction : 'all',
											fieldLabel : '所属院系',
											width : 120,
											listeners : {
												select : function(combo) {
													professionalstore.proxy = new Ext.data.HttpProxy(
															{
																url : '/schedule/queryProfessional?systems_id=' + combo.value
															});
													professionalstore.load();
												}
											}
										} ]
									}, {
										columnWidth : .2,
										layout : "form",
										items : [ {
											xtype : "hidden",
											name : "flag0",
											fieldLabel : "班级编号",
											width : 80
										} ]
									}, {
										columnWidth : .2,
										layout : "form",
										items : [ {
											xtype : 'combo',
											store : professionalstore,
											valueField : "professional_id",
											displayField : "professional_name",
											mode : 'local',
											forceSelection : true,
											blankText : '请选择所属专业',
											emptyText : '选择专业',
											hiddenName : 'flag3',
											editable : false,
											triggerAction : 'all',
											fieldLabel : '所属专业',
											width : 120
										} ]
									}, {
										columnWidth : .2,
										layout : "form",
										items : [ {
											xtype : "textfield",
											name : "flag1",
											fieldLabel : "班级名称",
											width : 80
										} ]
									} ]
						} ],
						tbar : [
								new Ext.Toolbar.TextItem('查询'),
								{
									xtype : "tbfill"
								},
								{
									pressed : true,
									text : '查询',
									listeners : {
										click : function() {
											Ext.StoreMgr
													.remove('professional_id');
											var flag0 = Ext.getCmp("form")
													.getForm().findField(
															'flag0').getValue();
											var flag1 = Ext.getCmp("form")
													.getForm().findField(
															'flag1').getValue();
											var flag2 = Ext.getCmp("form")
													.getForm().findField(
															'flag2').getValue();
											var flag3 = Ext.getCmp("form")
													.getForm().findField(
															'flag3').getValue();
											if (flag1 == "") {
												flag1 = "-";
											}
											;
											if (flag0 == "") {
												flag0 = "-";
											}
											;
											if (flag2 == "") {
												flag2 = "-";
											}
											;
											if (flag3 == "") {
												flag3 = "-";
											}
											;
											var flag = "" + flag0 + "," + flag1
													+ "," + flag2 + "," + flag3;
											getData(flag);//提交方法
										}
									}
								}, {
									xtype : "tbseparator"
								}, {
									pressed : true,
									text : '置空',
									listeners : {
										click : function() {
											form.form.reset();
										}
									}
								} ]
					});

			var viewport = new Ext.Viewport( {
				layout : 'border',
				title : '列表',
				items : [ form, grid, {
					region : 'south',
					contentEl : 'foot'
				} ]
			});
		});